package com.satis.compose.get.widget

import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material.Surface
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.constraintlayout.compose.ConstraintLayout
import androidx.constraintlayout.compose.ConstraintSet
import androidx.constraintlayout.compose.layoutId

/**
 * @author sunshaobei on 2023/3/27
 */
@Composable
fun GetCenter(modifier: Modifier = Modifier.fillMaxSize(),content:@Composable ()->Unit) {
    val centerSet = ConstraintSet(){
        val center = createRefFor("center")
        constrain(center){
            start.linkTo(parent.start)
            top.linkTo(parent.top)
            end.linkTo(parent.end)
            bottom.linkTo(parent.bottom)
        }
    }
    ConstraintLayout(centerSet,modifier = modifier) {
        Surface(modifier = Modifier.layoutId("center"),content = content)
    }
}